StringSplit

 

The StringSplit function truncates the separator in a string and returns it as an array of strings.

The size of the string array will change when it is returned, so you need to check the array size with the @strlen() function and write a script.

 

string[] @StringSplit(string source, string separator);

string[] @StringSplit(string source, string separator, int options, int count;

 

Parameters

string source : target string

string separator : separator

int options : option to remove empty items (0 - do not remove, 1 - remove)

int count : maximum number of separations

 

Return value

Returns a string separated by a separator as an array.

 

Example 1)

s = @StringSplit("aaa,bbb,ccc", ",");

 

Description : Store the strings "aaa,bbb,ccc,dddd" truncated by comma separators in an array.

 Result : s[0] = "aaa", s[1] = "bbb", s[2] = "ccc"

 

Example 2)

s = @StringSplit("aaa,bbb,ccc,,eee,fff", "," , 1, 4);

 

Description : Store the strings "aaa,bbb,ccc,,eee,fff" truncated by comma separator in an array.

                         However, the blank items are removed, and only up to 4 items are separated.

Result : s[0] = "aaa", s[1] = "bbb", s[2] = "ccc", s[3] = "eee,fff"

 

Example 3)

buf = "aaa,bbb,ccc,,eee,fff"

s = @StringSplit(buf, "," , 1, 4);

$ST_0000 = s[4];  // Script error occurred

 

Description : By separating strings up to 4 pieces, s[4] exceeds the index range, resulting in a script error.

Result : s[0] = "aaa", s[1] = "bbb", s[2] = "ccc", s[3] = "eee,fff"

 

Example 4)

buf = "aaa,bbb,ccc,,eee,fff"

s = @StringSplit(buf, ","); //Result : s[0] = "aaa", s[1] = "bbb", s[2] = "ccc", s[3] = "", s[4] = "eee", s[5] =  "fff"

length = @strlen(s);  // The length of the string array of 6 is returned

 

Description : Store the strings truncated by comma-separators in an array.

 

Version Information

Supported Version: 10.3.6.24 or higher

 

Related helps)

@StringIndexOf()

@StringSubstring()

@StringTrim()

@StringTrimEnd()

@StringTrimStart()

@StringUnicodeToAnsi()

@StringJson()

@strlen()